home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / env.com / ENVTEST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-10-24  |  3.7 KB  |  144 lines

  1. program EnvironmentTest; {             Version 2.5              88/10/04
  2.  
  3. Demonstrates ENVUNIT.PAS, handy little routines to simplify using the
  4. environment string.
  5.  
  6. COMPILE TO _DISK_ AND RUN FROM INSIDE THE TURBO INTEGRATED ENVIRONMENT
  7. to simulate nested programs (ie. one program "exec"ed by another).
  8.  
  9. This program is hereby donated to the public domain. It may be freely copied,
  10. used & modified without charge or fee.
  11.  
  12. Author        :  Mike Babulic
  13.                  3827 Charleswood Dr. N.W.
  14.                  Calgary, Alberta
  15.                  CANADA
  16.                  T2L 2C7
  17. Compuserve ID :  72307,314
  18.  
  19. }
  20.  
  21.   uses CRT,Dos,EnvUnit;
  22.  
  23.   var SomeFile: string;
  24.       oldPSP: word;
  25.       i : integer;
  26.  
  27.   procedure Wait;
  28.    begin
  29.      write('Press Return');
  30.        readln;
  31.      GotoXY(WhereX,WhereY-1);
  32.        ClrEol;
  33.    end;
  34.  
  35.   procedure WriteEnvStrings;
  36.     begin
  37.       writeln;writeln(EnvCount,' Environment Strings...');
  38.       writeln('     ',FirstEnv);
  39.       while not EOEnv do
  40.         writeln('     ',NextEnv);
  41.     end;
  42.  
  43.   procedure PathSearch;
  44.     begin
  45.       writeln;
  46.       writeln('     PathTo(''',somefile,''')...');
  47.       writeln('          ',PathTo(somefile));
  48.       writeln;
  49.       writeln('     FFind(''',somefile,''')...');
  50.       writeln('          ',FFind(somefile));
  51.       wait;
  52.     end;
  53.  
  54.   begin
  55.     writeln;
  56.     writeln('DOS Version ',Dos_Version/100.0:2:2);
  57.     writeln;
  58.     writeln('Program Path = ',MyPath);
  59.     writeln('        Dir  = ',MyDir );
  60.     writeln('        Name = ',MyName);
  61.     writeln('        Ext  = ',MyExt );
  62.     repeat
  63.       oldPSP := PSP;
  64.       UseParentPSP;
  65.       if oldPSP <> PSP then begin
  66.         writeln;
  67.         writeln('Parent  Name = ',ProgName);
  68.         writeln('        Path = ',ProgPath);
  69.       end;
  70.     until oldPSP = PSP;
  71.     writeln;
  72.     writeln('Root PSP Reached.');
  73.     writeln('   EnvSize = ',EnvSize,' bytes (max = ',MaxEnvSize,').');
  74.     UseMyPSP;
  75.     wait;
  76.  
  77.     writeln;
  78.     writeln('Back to MyPSP.');
  79.     writeln('   EnvSize = ',EnvSize,' bytes (max = ',MaxEnvSize,').');
  80.     writeln;
  81.     wait;
  82.  
  83.     WriteEnvStrings;
  84.     wait;
  85.  
  86.     writeln;writeln('Using the EnvStr() function...');
  87.     for i := 1 to EnvCount do
  88.       writeln(i:3,') ',EnvStr(i));
  89.     wait;
  90.  
  91.     somefile := 'COMSPEC';
  92.     writeln;writeln('GetEnv(''',somefile,''')...');
  93.       writeln('     ',GetEnv(somefile));
  94.     wait;
  95.  
  96.     writeln;writeln('Named Strings...');
  97.     writeln('     ',FirstNamed('PATH',';'));
  98.     while not EONamed do
  99.       writeln('     ',NextNamed);
  100.     wait;
  101.  
  102.     writeln;writeln('Paths...');
  103.     writeln('     ',FirstPath);
  104.     while not EONamed do
  105.       writeln('     ',NextPath);
  106.     wait;
  107.  
  108.     SomeFile := '*.com';
  109.     writeln;writeln('FSearch(''',somefile,''',GetEnv(''path''))...');
  110.     writeln('     ',FSearch(somefile,GetEnv('path')));
  111.     writeln;writeln('FExpand(''..''))...');
  112.     writeln('     ',FExpand('..'));
  113.     wait;
  114.  
  115.     writeln;writeln('AllowWildcards = ',AllowWildcards);
  116.     PathSearch;
  117.  
  118.     AllowWildcards := FALSE;
  119.     writeln;writeln('AllowWildcards = ',AllowWildcards);
  120.     PathSearch;
  121.  
  122.     somefile := 'autoexec.bat';
  123.     writeln;writeln('....but can still find files without wildcards.');
  124.     PathSearch;
  125.  
  126.     somefile := 'c:\test';
  127.     Writeln;writeln('SetPath(''',somefile,''') = ',
  128.       SetPath(somefile));
  129.  
  130.     WriteEnvStrings;
  131.     writeln;
  132.     writeln('ProgPath = ',ProgPath);
  133.     wait;
  134.  
  135.     writeln;writeln('SetPath('''') = ',SetPath(''));
  136.     somefile := 'comspec';
  137.     writeln;writeln('DelEnv(''',somefile,''')');
  138.       DelEnv(somefile);
  139.  
  140.     WriteEnvStrings;
  141.     writeln;
  142.     writeln('ProgPath = ',ProgPath);
  143.     wait;
  144.   end.